package top.tenebrous.yzl.im.config;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import top.tenebrous.yzl.im.entity.ImWebSocketProperties;

/**
 * @Description:
 * @Project: jestic-spring-boot
 * @Package: com.zy.tenebrous.jestic.config
 * @Author: zhangya
 * @CreateTime: 2023-01-19  10:27
 * @Version: 1.0.0
 */
@Slf4j
@Configuration
@Import(IMWorkPoolConfig.class)
public class IMContextAutoConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(IMContextAutoConfiguration.class);

    @Bean
    public EnableLoadImConfiguration enableLoadImConfiguration(ImWebSocketProperties webSocketProperties) {
        loadBanner(webSocketProperties);
        return new EnableLoadImConfiguration(webSocketProperties);
    }

    /**
     * 打印banner
     */
    private void loadBanner(ImWebSocketProperties webSocketProperties) {
        if (webSocketProperties.isEnablePrintBanner()) {
            System.out.println("yzl-im starting \n" +
                    ",--.   ,--.,-------.,--.       ,--.,--.   ,--. \n" +
                    " \\  `.'  / `--.   / |  |,-----.|  ||   `.'   | \n" +
                    "  '.    /    /   /  |  |'-----'|  ||  |'.'|  | \n" +
                    "    |  |    /   `--.|  '--.    |  ||  |   |  | \n" +
                    "    `--'   `-------'`-----'    `--'`--'   `--' \n");
            System.out.println(":: yzl-im author  :: zhangya ");
            System.out.println(":: yzl-im version :: " + webSocketProperties.getVersion() + "   ");
            System.out.println(":: yzl-im web     :: https://gitee.com/tenebrous/yzl-im-spring-boot.git ");
        }
    }
}
